package top.whysu.gps.controller.auth;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.whysu.gps.dto.auth.ClientCheckDTO;
import top.whysu.gps.dto.generate.RequestDTO;
import top.whysu.gps.dto.generate.ResponseDTO;
import top.whysu.gps.service.auth.AuthService;
import top.whysu.gps.utils.ResponseUtil;

import javax.annotation.Resource;

/**
 * 授权相关
 */
@Controller
@RequestMapping("/auth")
public class AuthController {

    @Resource
    private AuthService authService;

    /**
     * 客户端登录授权校验
     *
     * @return 服务器信息
     */
    @PostMapping("/clientCheck")
    @ResponseBody
    public ResponseDTO<Boolean> clientCheck(@RequestBody final RequestDTO<ClientCheckDTO> request) {
        return ResponseUtil.getSuccessResponse(request.getHeader(), authService.clientCheck(request.getBody().getClientMac()));
    }

}